/*
 * @Descripttion: 
 * @version: 
 * @Author: -ViJia
 * @Date: 2022-02-10 10:44:51
 * @LastEditors: -ViJia
 * @LastEditTime: 2022-03-11 14:29:44
 */
// import Server from '@/config/server';
import request from '@/utils/request';
import { showErrors, showError, showSuccess } from '@/utils/showMsg';

const state = {
  List: [],
  fields: [], // fields
};


const actions = {
  GetFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'index',
        scopedSlots: { customRender: 'indexNum' },
        align: 'center',
      },
      {
        title: 'ID',
        dataIndex: 'id',
        align: 'center',
      },
      {
        title: '商品标题',
        dataIndex: 'title',
        align: 'center',
        width: 250,
      },
      {
        title: '商品图标',
        dataIndex: 'logo',
        scopedSlots: { customRender: 'logo' },
        align: 'center',
      },
      {
        title: '分类',
        dataIndex: 'cate_id',
        scopedSlots: { customRender: 'cate' },
        align: 'center',
      },
      {
        title: '商品图片',
        dataIndex: 'image',
        scopedSlots: { customRender: 'image' },
        align: 'center',
      },
      {
        title: '商品比例',
        dataIndex: 'rate',
        align: 'center',
      },
      {
        title: '售价',
        dataIndex: 'sale_price',
        align: 'center',
      },
      {
        title: '原价',
        dataIndex: 'primary_price',
        align: 'center',
      },
      {
        title: '成本价',
        dataIndex: 'cost_price',
        align: 'center',
      },
      {
        title: '销量',
        dataIndex: 'sale_num',
        align: 'center',
      },
      {
        title: '库存',
        dataIndex: 'stock_num',
        align: 'center',
      },
      // {
      //   title: '药监类目',
      //   dataIndex: 'drug_type',
      //   scopedSlots: { customRender: 'drug_type' },
      //   align: 'center',
      // },
      {
        title: '排序',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
        align: 'center',
      },
      {
        title: '状态',
        dataIndex: 'status',
        scopedSlots: { customRender: 'status' },
        align: 'center',
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 150,
      }
    ];
    if(data == 'product'){
      fields.splice(11,1)
    }
    commit('setfields', fields);

  },
};

const mutations = {
  setfields(state, lists) {
    // console.log(state)
    state.fields = lists;
  },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations
};
